Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(headless): Support the automatic query correction feature for the insight use case #4598

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

SimonMilord
Copy link
Contributor

@SimonMilord SimonMilord commented Oct 25, 2024

SFINT-5680

IN THIS PR:

1- We now allow the SAPI to automatically correct the queries that contain a typo.

This was done by specifying the parameter queryCorrection in the search request for the insight panel.

To support this in the Headless library we needed to update Insight Search Actions Thunk Processor by adding a new logic to the processQueryCorrectionsOrContinue that handles the query correction feature using the modern way instead of the classic way that consists of sending a whole new search query with the corrected query returned by the SAPI.

In short: We now can correct with 1 request instead of 2.

2- Also added unit tests in headless to support this in the insight usecase

DEMO INSIGHT (queryCorrectionMode: 'next'):

Screen.Recording.2024-11-06.at.2.07.39.PM.mov

DEMO INSIGHT (queryCorrectionMode: 'legacy'):

legacy.insight.demo.auto.correct.mov

DEMO SEARCH (queryCorrectionMode: 'next'):

next.search.demo.auto.correct.mov

DEMO SEARCH (queryCorrectionMode: 'legacy'):

legacy.search.demo.auto.correct.mov

TESTS:

image

Copy link

github-actions bot commented Oct 25, 2024

Pull Request Report

PR Title

❌ Title should follow the conventional commit spec:
<type>(optional scope): <description>

Example: feat(headless): add result-list controller

Live demo links

Bundle Size

File Old (kb) New (kb) Change (%)
case-assist 236.8 236.8 0
commerce 341.5 341.5 0
search 412.8 412.8 0
insight 402.1 403.5 0.3
recommendation 249.1 249.1 0
ssr 406.3 406.3 0
ssr-commerce 353.7 353.7 0

SSR Progress

Use case SSR (#) CSR (#) Progress (%)
search 39 44 89
recommendation 0 4 0
case-assist 0 6 0
insight 0 27 0
commerce 0 15 0
Detailed logs search : buildInteractiveResult
search : buildInteractiveInstantResult
search : buildInteractiveRecentResult
search : buildInteractiveCitation
search : buildGeneratedAnswer
recommendation : missing SSR support
case-assist : missing SSR support
insight : missing SSR support
commerce : missing SSR support

@SimonMilord SimonMilord marked this pull request as ready for review November 6, 2024 20:29
@SimonMilord SimonMilord requested a review from a team as a code owner November 6, 2024 20:29
Copy link
Contributor

@mmitiche mmitiche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing missing to support the modern way of providing the query correct feature in the insight use case is the modification needed to the insight did you mean controller.

It currently does not expose any options to choose the the mode to be used, this need to be added to fully suppor this feature in the Headless library.

You can take this controller as an example:

export function buildDidYouMean(
engine: SearchEngine,
props: DidYouMeanProps = {}
): DidYouMean {
const controller = buildCoreDidYouMean(engine, props);

Copy link
Contributor

@mmitiche mmitiche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice job 👍 well done! I liked the tests created on the thunk processor!

@mmitiche
Copy link
Contributor

mmitiche commented Nov 8, 2024

Please also manually test that the whole loop is properly working in the two code paths you modified:

  1. When next analytics are used (you can enable that by setting the cookie coveo-pendragon) this will trigger the code path under insight-search/insight-search-actions-thunk-processor.ts

  2. When legacy analytics are used, this will trigger the code path under insight-search/legacy/insight-search-actions-thunk-processor.ts

export function buildDidYouMean(engine: InsightEngine): DidYouMean {
export function buildDidYouMean(
engine: InsightEngine,
props: DidYouMeanProps = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid breaking changes, I would set the default value of props to {queryCorrectionMode: 'legacy'} this client will not be switched from legacy to next automatically without their intervention.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we should set default value is 'legacy', if we enforce client to use new mode, then using 'next' is better. And we can document for user that if you upgrade, you need to update yours. Otherwise more and more user using 'legacy', it's not easy for us in the future to remove it

Copy link
Contributor

@mmitiche mmitiche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical change to be made to the headless controller,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants